load("02_02_m5s_fb_bg_jan15_entire_post_table.RData")
bg_fb_post$has_picture <- bg_fb_post$picture != ""


bg_fb_post$date <- as.Date(bg_fb_post$created_time, format = "%Y-%m-%dT%H:%M:%S+0000")

median_comment_has_pic <- 
  median(subset(bg_fb_post, has_picture == TRUE)$n_comments, na.rm = T)
median_comment_has_no_pic <- 
  median(subset(bg_fb_post, has_picture == FALSE)$n_comments, na.rm = T)
median_like_has_pic <-
  median(subset(bg_fb_post, has_picture == TRUE)$n_like, na.rm = T)
median_like_has_no_pic  <-
  median(subset(bg_fb_post, has_picture == FALSE)$n_like, na.rm = T)

p1 <- 
  ggplot(bg_fb_post, aes(x=n_comments, fill=has_picture)) + 
  geom_density(alpha=.5) + 
  scale_x_log10() +
  annotation_logticks(sides = "b") + 
  scale_fill_manual(labels = c('no','yes'), values = c('red', 'blue')) + 
  labs(x = 'comments per post') +
  geom_vline(xintercept = median_comment_has_no_pic) +
  geom_vline(xintercept = median_comment_has_pic) +
  guides(fill=FALSE)
p2 <- 
  ggplot(bg_fb_post, aes(x=n_like, fill=has_picture)) + 
  geom_density(alpha=.5) + 
  scale_x_log10() +
  annotation_logticks(sides = "b") + 
  labs(x = 'likes per post', fill = 'picture') +
  scale_fill_manual(labels = c('no','yes'), values = c('red', 'blue')) + 
  geom_vline(xintercept = median_like_has_no_pic) +
  geom_vline(xintercept = median_like_has_pic)
require(gridExtra)
grid.arrange(p1, p2, ncol=2, widths = c(1,1.1))